import request from '@/utils/request'

const userApi = {
  Login: '/frontend/User/login',
  Logout: '/frontend/User/logout',
  ForgePassword: '/auth/forge-password',
  Register: '/frontend/Membership/create',
  passwordEdit: '/frontend/User/passwordEdit',
  twoStepCode: '/auth/2step-code',
  SendSms: '/account/sms',
  SendSmsErr: '/account/sms_err',
  // get my info
  UserInfo: '/frontend/User/getInfo',
  UserMenu: '/user/nav',
  getSocietySelection: '/frontend/Membership/societyFinds',
  getSocietyDangerous: '/frontend/Itemship/argumentClassicFinds',
  getSocietyCreate: '/frontend/Itemship/create',
  getSocietyCreatecc: '/frontend/Membership/createacc ',
  getMembertypeFinds: '/frontend/Membership/membertypeFinds',
  getProjectCreatecc: '/frontend/Itemship/createacc '
}

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login (parameter) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/formdata;charset=UTF-8'
    }
  })
}

export function getSmsCaptcha (parameter) {
  return request({
    url: userApi.SendSms,
    method: 'post',
    data: parameter
  })
}

export function getInfo () {
  return request({
    url: userApi.UserInfo,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getCurrentUserNav () {
  return request({
    url: userApi.UserMenu,
    method: 'get'
  })
}

export function logout (parameter) {
  return request({
    url: userApi.Logout,
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/formdata;charset=UTF-8'
    }
  })
}
export function Register (parameter) {
  return request({
    url: userApi.Register,
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function getSocietySelection (parameter) {
  return request({
    url: userApi.getSocietySelection,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getSocietyDangerous (parameter) {
  return request({
    url: userApi.getSocietyDangerous,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

export function getMembertypeFinds (parameter) {
  return request({
    url: userApi.getMembertypeFinds,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

export function getSocietyCreate (parameter) {
  return request({
    url: userApi.getSocietyCreate,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

export function getSocietyCreatecc (parameter) {
  return request({
    url: userApi.getSocietyCreatecc,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

export function getProjectCreatecc (parameter) {
  return request({
    url: userApi.getProjectCreatecc,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

/**
 * get user 2step code open?
 * @param parameter {*}
 */
export function get2step (parameter) {
  return request({
    url: userApi.twoStepCode,
    method: 'post',
    data: parameter
  })
}
export function passwordEdit (parameter) {
  return request({
    url: userApi.passwordEdit,
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/formdata;charset=UTF-8'
    }
  })
}
